package com.cn.mapper;

import com.cn.pojo.City;
import com.cn.pojo.Province;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 7.3.4 一对多查询
 */
public interface ProvinceMapper {
    @Select("select * from province where p_id = #{id}")
    @Results({
            @Result(id = true,column = "p_id", property = "pId"),
            @Result(column = "p_name", property = "pName"),
            @Result(column = "p_id",property = "cityList",many = @Many(select = "com.cn.mapper.CityMapper.findCityByProvinceId"))
    })
    Province findProvinceById(Integer id);
}
